package com.hui.wanxin.web.common.mq.listener;

import com.hui.wanxin.web.common.mq.entity.MqConst;
import com.hui.wanxin.web.common.mq.entity.SmsVo;
import com.hui.wanxin.web.common.service.SmsService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author: 灰灰
 * @date: 2023年10月14日 12:49
 * @ClassName: SmsListener
 * @Description: TODO
 */

public class SmsListener {

    @Autowired
    private SmsService smsService;

    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue(name = MqConst.QUEUE_SMS_ITEM,durable = "true"),
                    exchange = @Exchange(name = MqConst.EXCHANGE_DIRECT_SMS),
                    key = MqConst.ROUTING_SMS_ITEM
            )
    })
    public void consume(SmsVo smsVo, Message message, Channel channel){
        smsService.sendMessage(smsVo);
    }

}
